package cn.itcast.foodapp2;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;

import org.json.JSONException;
import org.json.JSONObject;

import cn.itcast.foodapp2.net.NetUtil;

public class CommentsDetailActivity extends AppCompatActivity {
    private static final String TAG = "CommentsDetailActivity";
    int id = 0;
    String foodName;
    TextView mTvFoodName,mTvComments;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_comments_detail);
        id = getIntent().getIntExtra("id", 1);
        foodName = getIntent().getStringExtra("foodName");
        initView();
        initData();
        initEvent();
    }

    private void initEvent() {

    }

    private void initData() {
        mTvFoodName.setText(foodName + "");
        new Thread(new Runnable() {
            @Override
            public void run() {
                String url = "http://42.48.39.55:8081/foodserver/findcomments/"+id;
                JSONObject jsonObject = new JSONObject();

                String data = NetUtil.getData(jsonObject, url);
                Log.e(TAG, "run: "+data );
            }
        }).start();
    }

    private void initView() {
        mTvFoodName = findViewById(R.id.tv_food_name_comments_detail);
        mTvComments = findViewById(R.id.tv_food_comments_detail);
    }
}